import { ipcMain } from 'electron'
import { sqDelete, sqInsert, sqQuery, sqUpdate } from './index'

ipcMain.handle("project-list", async () => {
  return await sqQuery({ sql: 'select * from project' })
})

ipcMain.handle("project-add", async (event, data) => {
  return await sqInsert({ table:"project", data:data })
})

ipcMain.handle("project-edit", async (event, data) => {
  return await sqUpdate({
    table: "project",
    data: data,
    condition:`id = ${data.id}`
  })
})

ipcMain.handle("project-delete", async (event, data) => {
  return await sqDelete({
    table: "project",
    condition:`id = ${data.id}`
  })
})
